package app.netant.finishbook.uww3;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;

public class Uww3Detail extends BaseDetail {

	public Uww3Detail(String netSite) {
		super(netSite);
		this.preHref = "https://www.3uww.cc";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select(".globalBox #pageMain .mainBody .pageMainArea #downInfoArea #downInfoTitle");
		if(parts.size()>0){
			String title = parts.get(0).text().trim();
			int start = title.indexOf("《");
			int end = title.lastIndexOf("》");
			if(start>=0 && end > start){
				title = title.substring(start+1,end);
			}
			System.out.println("【Title】:"+title);
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".zip");
		}
	}

	@Override
	public void analyseTags() {
		Elements parts = this.select(".globalBox #pageMain .mainBody .pageMainArea #downInfoArea .downInfoRowL");
		if(parts.size()>1){
			String tags = parts.get(1).text().trim();
			System.out.println(tags);
			this.splitTags(tags, false);
		}
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select(".globalBox #pageMain .mainBody .pageMainArea #downInfoArea .mainstory #mainSoftIntro p");
		if(parts.size()>0){
			String memo = parts.get(0).text().trim();	
			System.out.println("【Memo】:"+memo);
			this.entity.setNovelMemo(memo);
		}
	}

	@Override
	public void analyseHref() {
		
		int startIdx = this.netSite.lastIndexOf("/");
		int endIdx = this.netSite.lastIndexOf(".");
		String number = this.netSite.substring(startIdx+1,endIdx);
		
		String url = "https://txt.3uww.cc/home/down/zip/id/"+number;
		
		System.out.println("【Href】:"+url);
		this.entity.setDownPath(url);
		
	}
	
	@Override
	public void analyseType() {
		Elements parts = this.select("#globalNavmid #topclassmerber .li_l a");
		if(parts.size()>1){
			String type = parts.get(1).text();
			System.out.println("【Type】:"+type);
			this.entity.setNovelType(type);
		}
	}
	
	public static void main(String[] args) {
		Uww3Detail detail = new Uww3Detail("https://www.3uww.cc/down/201403/24025.html");
		detail.test();
	}



}
